home *** CD-ROM | disk | FTP | other *** search
- --
- -- This file describes the tool tip commands used for the menus
- --
-
- function KillToolTipsPopup()
- if( not( ToolTipsWindow == nil ) and ToolTipsWindow.IsValid() ) then
- ToolTipsWindow.Destroy();
- end
- end
-
- function ToolTipsPopup( text )
- if( ToolTipsWindow == nil or not(ToolTipsWindow.IsValid()) ) then
- G.Create( "MenuData/ToolTipsTextCog.xml" );
- end
-
- -- Make it slightly offset from the cursor
- local x = G.GetMouseX()
-
- if( x < 0.5 ) then
- x = x + 0.26
- else
- x = x - 0.26
- end
-
- local y = G.GetMouseY()
-
- if( y < 0.25 ) then
- y = y + 0.26
- else
- y = y - 0.26
- end
-
- ToolTipsWindow.SetGuiPosition( "ToolTipsTextBox", Vector3( x, y, 0 ) )
- ToolTipsWindow.SetGuiText( "ToolTipsTextBox", text, 0 );
-
- -- TextFadeTime = TotalTextDur
- end
-
-
- prevToolTipObj = ""
- ToolTipShowDelay = 1.75
- ToolTipTimer = 0
-
- function UpdateToolTip()
-
- -- Check what object the cursor is hovering over:
- if( not( GuiObjectOver == prevToolTipObj ) ) then
- -- if DIFFERENT hide the current text, update the text, reset the timer
- KillToolTipsPopup()
- prevToolTipObj = GuiObjectOver
- ToolTipTimer = 0;
- else
- -- else increase the timer
- ToolTipTimer = ToolTipTimer + GameTimeDiff
- end
-
- --
- if( ToolTipTimer > ToolTipShowDelay ) then
- -- If the timer is over the mininum, set the text visible:
- -- Sadly, you don't now who's this is, just check Traitor, MainMenu & HUD
- local descText = ""
- if( not( MainMenu == nil ) and MainMenu.IsValid() ) then
- descText = MainMenu.GetDescription( prevToolTipObj );
- end
-
- if( descText == "" and not( HUD == nil ) and HUD.IsValid() ) then
- descText = HUD.GetDescription( prevToolTipObj );
- end
-
- if( descText == "" and not( Traitor == nil ) and Traitor.IsValid() ) then
- descText = Traitor.GetDescription( prevToolTipObj );
- end
-
- if( not(descText == "") ) then
- ToolTipsPopup( descText )
- end
-
- -- Some tips are special (Traps, TowerHP) So they need special code:
- end
-
- end
-
- GMain[ "UpdateToolTip" ] = UpdateToolTip;
-
-